Video camera, controller, and method for controlling output bitrate of a video encoder

ABSTRACT

A controller and a method for controlling output bitrate of a video encoder when encoding a video stream. The method for controlling output bitrate of a video encoder when encoding a video stream comprises: receiving weather forecast data for a location where the video stream is captured; predicting, based on the weather forecast data, a future increase in output bitrate of the video encoder due to weather affecting contents of the video stream; and reducing the output bitrate of the video encoder by increasing a compression level of the video stream so as to compensate for the future increase in output bitrate of the video encoder.

FIELD OF INVENTION

The present teachings relate to the field of video encoding. Inparticular, it relates to control of an output bitrate of a videoencoder.

BACKGROUND

Video cameras are commonly used for surveillance. In surveillanceapplications, a video camera is arranged to monitor a scene by capturinga video stream depicting the scene. The video stream is then encodedprior to being stored. The encoded video stream may be stored in thevideo camera itself, but typically it is transmitted over a network to,for instance, a server where it is stored. If it is found out that someevent of interest has happened in the scene, such as a burglary takingplace, it is possible to access the encoded video stream from thestorage and view it to find evidence of the event of interest.

The video encoder of the video camera described above thus produces acertain amount of stored video data during a time period. Since thestorage space may be a limiting factor, it may be of interest to controlthe amount of video data that is produced by the video encoder, i.e.,the output bitrate of the video encoder, such that the available storagespace lasts for a time period of pre-set duration, such as a week or amonth.

At the same time, it is of course of interest that the output bitrate ofthe video encoder is allowed to vary so as to capture bitrate peakswhich are caused by interesting motion in the video stream (such as theburglar of the example above), while restricting bitrate peaks causedby, for instance, noise or other factors which have a negative impact onthe video quality. While, for instance, night time noise is easy to planfor, another factor that may have a negative impact on the video qualityis weather events such as rain, snow, fog or heavy winds. These weatherevents will typically affect the contents of the video stream andintroduce undesirable noise or motion, thereby giving rise to bitratepeaks that provide no additional surveillance information. For example,a weather event may cause the video encoder to spend most of its weeklyor monthly allocated bits on a weather caused peak in bitrate alreadythe first day, leaving few bits for the remaining time period.

Although there is prior art, including U.S. 2015/0358537 A1, thatgenerally links weather data to compression, there is no prior teachingof how to restrict or compensate for bitrate peaks caused by futureweather events. There is thus room for improvements.

SUMMARY

In view of the above, it is thus an object of the present disclosure torestrict or compensate for bitrate peaks caused by future weatherevents.

According to a first aspect, the above object is achieved by a methodfor controlling output bitrate of a video encoder when encoding a videostream, comprising: receiving weather forecast data for a location wherethe video stream is captured; predicting, based on the weather forecastdata, a future increase in output bitrate of the video encoder due toweather affecting contents of the video stream; and reducing the outputbitrate of the video encoder by increasing a compression level of thevideo stream so as to compensate for the future increase in outputbitrate of the video encoder.

According to this method, weather forecast data is used to predict afuture increase in output bitrate of a video encoder. When a futureincrease in output bitrate of the video encoder has been predicted, acompression level applied by the video encoder when compressing thevideo stream is increased. In this way, the output bitrate of the videoencoder goes down, and hence the future increase in output bitrate canbe compensated for. The compression level may be increased in relationto a current compression level. The current compression level maycorrespond to a nominal compression level which is set at the start ofthe time interval. However, the current compression level may alsocorrespond to the compression level as adjusted after the start of thetime interval, such as during the time period from the start of the timeinterval until a current time point of the time interval.

The term compression level as used herein generally refers to how muchthe video stream is compressed. This is typically a parameter of thevideo encoder that may be varied. For example, the compression level maybe in the form of a quantization parameter.

By contents of the video stream as used herein is generally meant theimage contents of the frames of the video stream. Weather, such as rain,snow, fog or wind, will typically affect the image contents of the videostream by introduction of noise or motion in the frames of the videostream.

The weather forecast data may be in the form of various weather-relatedparameters. The weather-related parameters may be used to predict thefuture increase in output bitrate caused by weather, e.g., by comparingthe parameters to various predetermined thresholds. More specifically,the weather forecast data may comprise a parameter being indicative of aweather condition, and wherein, in the step of predicting, a futureincrease in output bitrate is predicted if the parameter falls outside apredetermined parameter interval.

In some applications, the control of the output bitrate of the videoencoder aims at controlling the amount of data that is output of theencoder such that the total number of bits that are output during acertain time interval does not exceed a certain level. In other words,the video encoder may have a bit budget that it may spend during acertain time interval. As an unexpected bit cost comes up, hererepresented by the weather causing a future increase in bitrate, thevideo encoder has to take action to compensate for the unexpected bitcost. Otherwise the bit budget will likely be exceeded in the end. Themethod may therefore further comprise setting a bit budget correspondingto a maximum number of bits that are allowed to be output from the videoencoder during a time interval, wherein, in the step of reducing theoutput bitrate, the compression level of the video stream is increasedduring at least a portion of the time interval such that the bit budgetis not exceeded.

The compression level may thus be increased in order to compensate forunexpected bit costs in the form of bitrate peaks caused by weather.However, the compression level may not only be increased in order tocompensate for unexpected bit costs, but it may repeatedly during thetime interval be adjusted to make sure that the bit budget is notexceeded as the time interval comes to an end. For example, the methodmay further comprise adjusting the compression level of the video streamperiodically during the time interval such that the bit budget is notexceeded. This may include increasing the compression level if thenumber of bits that has been spent so far during the time interval ishigher than expected, or decreasing the compression level if the numberof bits that has been spent so far is lower than expected.

The expected number of spent bits may correspond to the average numberof bits that were spent at the same point in time for previous timeintervals of the same duration. In this respect, a parallel may be drawnto a monthly household budget. In a monthly household budget, there areexpected costs and unexpected costs. The expected costs may correspondto a rent that has to be paid at the end of the month, and theunexpected costs may correspond to a bill for repairing a water leakthat was not anticipated. The expected costs are easy to plan for inview of costs that usually come up each month, whereas the unexpectedcosts are much more difficult to handle. Still, the monthly budget hasto cover both expected and unexpected costs, and if an unexpected costcomes up, the expenses of the household have to be reduced in one way orthe other so that there is enough money to pay the bills at the end ofthe month.

Returning to the bit budget of the video encoder, there are unexpectedcosts corresponding to the bit costs that are caused by weather asexplained above, and there may also be expected bit costs. Similar tothe household budget, the expected bit costs and the time point of thetime interval when they occur may be deduced from historical data. Forexample, bitrate data from previous time intervals of the same durationmay be collected from which an average temporal variation of outputbitrate of the video encoder during the time interval may be calculated.The so calculated average temporal variation curve may for example beused to, at any time point within the time interval, estimate the bitcosts which on average occur up until that time point of the timeinterval. This may be used to control the output bitrate so as to makesure that the bit budget is not exceeded.

In more detail, the method may further comprise receiving previouslycollected bitrate data indicating an average temporal variation ofoutput bitrate of the video encoder during the time interval, andcalculating, from the previously collected bitrate data, a number ofbits which on average is output from the video encoder at a current timepoint of the time interval, wherein, in the step of adjusting thecompression level periodically, the compression level is increased if anumber of bits that has been output from the video encoder at thecurrent time point exceeds the calculated number of bits which onaverage is output from the video encoder at the current time point, andthe compression level is decreased if the number of bits that has beenoutput from the video encoder at the current time point is below thecalculated number of bits which on average is output from the videoencoder at the current time point.

The previously collected bitrate data may also be used to set a nominalcompression level of the video stream. The nominal compression level mayserve as a base level with respect to which the compression level isadjusted, i.e., increased or decreased. In more detail, the method mayfurther comprise: receiving previously collected bitrate data indicatingan average temporal variation of output bitrate of the video encoderduring the time interval, and setting a nominal compression level of thevideo stream based on the previously collected bitrate data during thetime interval such that the bit budget for the time interval is notexceeded, wherein, in the step of reducing the output bitrate of thevideo encoder, the compression level is increased from said nominalcompression level.

In the above, a nominal compression level thus refers to a compressionlevel which is set on basis of the average temporal variation curve,i.e., the expected future costs, such that the expected future bit costswill be covered by the bit budget. The nominal compression level istypically set at the outset of the time interval, and may hence serve asa start value for the compression level.

The method may further comprise keeping track of a number of bits that,according to the bit budget, remains to be output from the video encoderduring the time interval, and a remaining time of the time interval,wherein, in the step of reducing the output bitrate of the videoencoder, the compression level is increased by an amount which isdetermined based on at least the number of bits that remains to beoutput from the video encoder during the time interval, and theremaining time of the time interval. The method may thus, at all times,keep track of how many bits that are left to spend during the remainderof the time interval, and the remaining time. Based on that information,the amount by which the compression level is increased to compensate forthe weather caused increase in bitrate may be set.

The amount may further be determined based on the previously collectedbitrate data indicating an average temporal variation of output bitrateof the video encoder during the time interval. In this way, the futureexpected bit costs, which may be deduced from the average temporalvariation curve, may also be taken into account when deciding by howmuch the compression level should be increased to compensate for theweather caused increase in bitrate.

The portion of the time interval during which the compression level isincreased may be selected in different ways. For example, the at least aportion of the time interval may be selected based on the weatherforecast data, such that the compression level of the video stream isincreased during the predicted future increase of output bitrate of thevideo encoder. In other words, the compression level may be increasedwhen the weather is predicted to occur.

The at least a portion of the time interval may also be selected basedon previously collected bitrate data indicating an average temporalvariation of output bitrate of the video encoder during the timeinterval. For example, assuming that it is important to catch thebitrate peaks in the average temporal variation of output bitrate, thecompression level may be increased when there are no bitrate peaks inthe average temporal variation of output bitrate. Such portions may beidentified as the time portions when the average temporal variation ofoutput bitrate falls below a threshold. More specifically, the at leasta portion of the time interval may be selected based on the previouslycollected bitrate data such that the compression level of the videostream is increased during a portion of the time interval when thepreviously collected bitrate data exceeds a predetermined threshold orduring a portion of the time interval when the previously collectedbitrate data is below a predetermined threshold.

Alternatively, the compression level of the video stream may beincreased for the remainder of the time interval. In this way, thecompensation of the weather caused increase in bitrate is distributedover the remainder of the time interval.

According to yet an example, the at least a portion of the time intervalmay be selected based on contents in the video stream. For example, thecompression level may be increased during time portions when the levelof motion in the video stream is below a threshold. In that way, one canmake sure that interesting portions of the video stream are stillencoded with a high quality.

According to a second aspect, the above object is achieved by acontroller for controlling output bitrate of a video encoder whenencoding a video stream, comprising: a receiver configured to receiveweather forecast data for a location where the video stream is captured;a predictor configured to predict, based on the weather forecast data, afuture increase in output bitrate of the video encoder due to weatheraffecting contents of the video stream; and an output bitrate adjusterconfigured to reduce the output bitrate of the video encoder byincreasing a compression level of the video stream so as to compensatefor the future increase in output bitrate of the video encoder.

According to a third aspect, the above object is achieved by a videocamera comprising a video encoder and a controller according to thesecond aspect for controlling output bitrate of the video encoder.

According to a fourth aspect, there is provided a computer programproduct comprising a computer-readable medium with computer-codeinstructions adapted to carry out the method of the first aspect whenexecuted by a device having processing capability.

The second, third, and fourth aspects may generally have the samefeatures and advantages as the first aspect. It is further noted thatthe present teachings relate to all possible combinations of featuresunless explicitly stated otherwise.

BRIEF DESCRIPTION OF THE DRAWINGS

A more detailed understanding may be had from the following description,given by way of example in conjunction with the accompanying drawingswhere:

FIG. 1 is a schematic illustration of a video camera according toembodiments;

FIG. 2 is a schematic illustration of a controller for controlling anoutput bitrate of the video encoder of the video camera of FIG. 1;

FIG. 3 is a flowchart of a method for controlling output bitrate of avideo encoder when encoding a video stream according to embodiments;

FIG. 4 is a flowchart of a method for controlling output bitrate of avideo encoder when encoding a video stream according to embodiments; and

FIGS. 5a-5d each illustrates output bitrate of a video encoder as afunction of time.

DETAILED DESCRIPTION

The present teachings will now be described more fully hereinafter withreference to the accompanying drawings, in which embodiments are shown.This present teachings may, however, be embodied in many different formsand should not be construed as limited to the embodiments set forthherein; rather, these embodiments are provided for thoroughness andcompleteness, and to fully convey the scope of the present teachings tothe skilled person. The systems and devices disclosed herein will bedescribed during operation.

FIG. 1 illustrates a video camera 100. The video camera comprises asensor 102, an image pipeline 104, and a network interface 112.

The video camera 100 is arranged, via sensor 102, to capture a videostream. The video stream comprises a sequence of frames of image data.The image data, as captured by the sensor 102, is in the form of imageraw data. That image data in its raw format is forwarded, frame byframe, to the image pipeline 104 where it is processed and encoded. Forthis purpose, the image pipeline 104 comprises an image processor 106and a video encoder 108. The image processor 106 may in variousprocessing steps process the image raw data of the frames in a manneralready known in the art. The processed image data is then encoded byvideo encoder 108.

The video encoder 108 outputs the encoded image data of the video streamin the form of a bitstream. The bitstream is typically sent out over anetwork, via network interface 112, to a storage unit, which forinstance may be located on a server. Alternatively, the video camera 100may itself comprise a storage, typically in the form of non-volatilememory, for storing the encoded video stream.

The video encoder 108 thus outputs a bitstream. The rate at which thevideo encoder 108 outputs bits, i.e., the output bitrate of the videoencoder 108 may be controlled by a controller 110. The controller may beimplemented as a part of the video encoder 108 or as a separate unit.For this purpose, the controller 110 may send a control signal to thevideo encoder 108. The control signal may particularly instruct thevideo encoder 108 to adjust its compression level. In this respect, thecompression level may, e.g., refer to the quantization parameter of theH.264 standard. Alternatively, or additionally, the compression levelmay be adjusted by adjusting the frame rate of the video encoder 108. Asthe compression level is increased, the output bitrate of the videoencoder 108 will decrease, and vice versa.

The controller 110 and its components are shown in more detail in FIG.2. The controller 110 comprises a receiver 1101, a predictor 1102, andan output bitrate adjuster 1103.

The controller 110 thus comprises various components 1101, 1102, 1103which are configured to implement the functionality of the controller110. In particular, each illustrated component corresponds to afunctionality of the controller 110. Generally, the controller 110 maycomprise circuitry which is configured to implement the components 1101,1102, 1103 and, more specifically, their functionality.

In a hardware implementation, each of the components 1101, 1102, 1103may correspond to circuitry which is dedicated and specifically designedto provide the functionality of the component. The circuitry may be inthe form of one or more integrated circuits, such as one or moreapplication specific integrated circuits. By way of example, the outputbitrate adjuster 1103 may thus comprise circuitry which, when in use,reduces the output bitrate of the video encoder by increasing thecompression level.

In a software implementation, the circuitry may instead be in the formof a processor, such as a microprocessor, which in association withcomputer code instructions stored on a (non-transitory)computer-readable medium, such as a non-volatile memory, causes thecontroller to carry out any method disclosed herein. In that case, thecomponents 1101, 1102, 1103 may thus each correspond to a portion ofcomputer code instructions stored on the computer-readable medium, that,when executed by the processor, causes the controller 110 to carry outthe functionality of the component.

It is to be understood that it is also possible to have a combination ofa hardware and a software implementation, meaning that the functionalityof some of the components 1101, 1102, 1103 are implemented in hardwareand others in software.

The operation of the controller will be described in the following withreference to FIGS. 1 and 2 and the flow chart of FIG. 3.

In step S302, the receiver 1101 receives weather forecast data. Theweather forecast is with respect to a location where the video stream iscaptured, i.e., with respect to a location of the video camera 100. Theweather forecast data may be received from the network via networkinterface 112. For example, the weather forecast data may be receivedfrom an internet-based weather forecast service.

The weather forecast data is generally indicative of future weather atthe location of the video camera 100. For example, the weather forecastdata may be in the form of one or more parameters. This may include rainfall levels, snow levels, moisture levels, temperature, and/or windspeed. These parameters may alone or together be indicative of a weathercondition at the location of the video camera 100. For example, the rainfall level is indicative of rain fall, the snow level is indicative ofsnow fall, the moisture level together with a temperature is indicativeof fog, and the wind speed is indicative of wind. The weather forecastdata may also indicate when in time the weather condition, as specifiedby the one or more parameters, will occur.

In step S304, the predictor 1102 predicts, based on the weather forecastdata, a future increase in the output bitrate of the video encoder 110.In an outdoor situation, i.e., where the video camera 100 is locatedoutdoors, various weather conditions will affect the contents of thevideo stream, such as introducing undesirable noise or motion in thevideo stream. For example, rain or snow fall will give rise to anincreased noise level in the images, and heavy winds may cause branchesand leaves of trees in the scene to move. Such noise and motion isundesirable from a surveillance point of view since it adds noadditional surveillance information. Still, the noise or motion causedby the weather condition will be in the video stream, and it will causean increase in output bitrate since noise and motion are costly toencode.

As described above, the weather forecast data is indicative of thefuture weather condition at the location of the camera 100, and maytherefore be used to predict that, and even when, there will be a futureincrease in the output bitrate of the video encoder 108. For example,the predictor 1102 may compare the one or more parameters of the weatherforecast data to some predefined parameter intervals to see whether theyfall inside or outside the predefined parameter intervals. A parameterfalling outside a predefined parameter interval, may serve as anindication that there is a weather condition that will affect the imagedata such that there in the end will be an increase in output bitrate.Accordingly, the predictor 1102 may predict a future increase in outputbitrate if one, or several, parameters fall outside the predefinedparameter intervals.

When the predictor 1102 has predicted a future increase in outputbitrate due to weather affecting the image contents of the video streamas explained above, the method proceeds to step S306. In step S306, theoutput bitrate adjuster 1103 takes action to compensate for thepredicted future increase in output bitrate. In more detail, the outputbitrate adjuster 1103 takes a decision to increase the compression levelof the video encoder 108. The output bitrate adjuster 1103 may, e.g.,send a control signal to the video encoder 108 that it should increasethe compression level. For example, the quantization parameter of thevideo encoder 108 could be increased. Alternatively, or additionally,the frame rate of the encoded video stream could be decreased. As aresult, when the compression level of the video encoder 108 isincreased, the output bitrate will be reduced. In this way, thepredicted increase in bitrate due to the weather condition may becompensated for. Preferably, the compression level is increased suchthat the increase in bitrate due to the weather condition is completelycompensated for.

The output bitrate adjuster 1103 may control the video encoder 108 toincrease the compression level immediately, i.e., as soon as a badweather condition has been predicted. However, the output bitrateadjuster 1103 may also control the video encoder 108 to increase thecompression level when the weather condition is expected to occur, i.e.,during the predicted future increase of output bitrate. The increase incompression level may be until further notice, or it may be momentary,i.e., time limited. For example, the increase in compression level maybe limited to apply only during the time period when the increase inbitrate due to the weather condition is predicted to occur. According tostill another option, the time period when the compression level shouldbe increased may be selected based on contents in the video stream, suchas the level of motion in the video stream. In more detail, thecontroller 110 may have access to the video stream to be encoded, e.g.,via the video encoder 108. The output bitrate adjuster 1103 may thendecide to increase the compression level during periods when, forinstance, the level of motion in the video stream is below a threshold.

The amount of the increase of the compression level generally depends onthe severity of the expected weather condition. The “stronger” theweather, the more the compression level has to be raised. However, inpractice this will also depend on the location of the camera, andempirical tests are needed to find an appropriate increase of thecompression level for a camera at a specific location. By way ofexample, the camera may be mounted in a protected spot, where it ishardly impacted by weather, or it may be in an exposed location, such ason a bridge over open water, where even fairly mild weather has largeeffect on the image contents and the resulting bitrate. Thus, theweather susceptibility of the camera has to be tested in order to findout by how much the compression level should be raised in order tocompensate for a future increase in bitrate caused by weather.

As described with reference to FIG. 1, the encoded video stream may bestored. In some situations, there is only a certain amount of storagespace available, and it is desirable that the available storage spaceshould last for a predefined amount of time, such as a day, a week or amonth. In other words, there may be a certain bit budget which defines amaximum number of bits that are allowed to be output from the videoencoder 108 during a time interval. In such situations, the controller110 should not only control the output bitrate of the video encoder 108to compensate for bitrate peaks caused by weather, but the controller110 should additionally control the output bitrate, by adjusting thecompression level, such that the bit budget is not exceeded. The methoddescribed with reference to FIG. 3 may also be implemented in thecontext of such a situation. This will be described in more detail inthe following with reference to FIGS. 1 and 2, FIGS. 5a-d , and the flowchart of FIG. 4.

In step S402, a bit budget is set for a time interval. The bit budgetcorresponds to a maximum number of bits that are allowed to be outputfrom the video encoder 108 during a time interval T. The bit budget istypically an input parameter which may be communicated to the controller110 via the network interface 112 and the receiver 1101. It may be basedon the capacity of available storage and a desired retention time.

In step S404, the controller 101 may, via the receiver 1101 receivepreviously collected bitrate data. The previously collected bitrate datamay be in the form of a curve which describes the temporal variation ofthe average output bitrate of the video encoder 108 during a timeinterval T. Such a curve may be calculated by collecting output bitratedata from a plurality of time intervals T in the past, such as bitratedata from a plurality of weeks in the past, and calculating an averagewith respect to the plurality of time intervals. An example of such acurve 500 is illustrated in FIG. 5a . The area under the curve 500,i.e., the time integral of the curve, is hence the average number ofbits that are output during the time period T. The average number ofbits that are output during the time period T is assumed to be equal toor lower than the maximum number of output bits allowed by the bitbudget. In this sense, the curve 500 may be seen as a distribution ofthe available bit budget over time. Similarly, the integral of the curveup till time t_0 is the average number of bits that are output untiltime t_0. In other words, from the curve 500, the expected number ofbits that are output before a certain point in time may be calculated.

Previously collected bitrate data may also be used to set a nominalcompression level which may serve as a base level, or reference level,for the compression level. The compression level may then be adjusted inrelation to the nominal compression level, e.g., in steps S406 and S412described below. The nominal compression level is preferably set at theoutset of the time interval, and may hence be seen as a start value ofthe compression level. The nominal compression level may be set based onthe previously collected bitrate data. In more detail, the previouslycollected bitrate data may be associated with a compression level thatwas used by the video encoder 108 when generating the previouslycollected bitrate data. If it is found that the previously collectedbitrate data does not fit within the desired bit budget, such as if thearea under the curve 500 exceeds the bit budget, the nominal compressionlevel should be higher than the compression level associated with thepreviously collected bitrate data, and vice versa. In practice, bitratedata may be collected for various compression levels, and on basis ofthat a nominal compression level may be set to correspond to acompression level being associated with a bitrate curve that does notexceed the desired bit budget.

In step S406, the output bitrate adjuster 1103 adjusts the compressionlevel of the video stream. In more detail, the output bitrate adjuster1103 may during the time interval T periodically adjust the compressionrate. For example, if the time interval T corresponds to a day (24hours), the compression rate may be updated on an hourly basis. Inparticular, the compression rate may be adjusted to make sure that thebit budget is not exceeded at the end of the time interval T. For thispurpose, the output bitrate adjuster may, via input from the videoencoder 108, keep track of the number of bits that are spent during thetime interval. The output bitrate adjuster 1103 may then compare thebits that actually were output from the video encoder 108 at time pointt_0, say, to the expected number of output bits at time t_0. Asdescribed above, the latter may be found by integrating the curve 500 ofFIG. 5a up to time point t_0. If the number of bits that were output ofthe encoder 108 exceeds the expected number of output bits, the outputbitrate adjuster 1103 may increase the compression level. If the numberof bits that were output of the encoder 108 is lower than the expectednumber of output bits, the output bitrate adjuster 1103 may decrease thecompression level.

Generally, the amount of the compression level adjustment may be done indifferent ways as is known in the art. For example, a proportionalcontrol strategy may be used where the size of the adjustment isproportional to the difference between the actual number of bits thatwere output from the encoder and the expected number of output bits.

As an alternative, or a complement, to adjusting the compression levelperiodically, the compression level may also be adjusted if it is foundthat the number of bits that were actually output differs from theexpected number of output bits by more than a threshold amount.

In step S408, weather forecast data is received in accordance with whatwas described with respect to step S302 of FIG. 3. The weather forecastdata may be received at any time point during the time interval T. Inthe example of FIG. 5a , the weather forecast data is assumed to bereceived at time t_1.

It is to be noted that there is no specific order of steps S406 andS408. On the one hand, the adjustment of step S406 is carried out atseveral occasions during the time interval T, such as periodically (attime points t_0, 2t_0, 3t_0 . . . of FIG. 5a ) during the time intervalT. On the other hand, step S408 may happen at any time during the timeinterval T, such as at time t_1 of FIG. 5a . As a matter of fact, stepS408 may trigger an adjustment of the compression level (see steps S410,S412 below) which is in addition to the regular adjustments described instep S406.

In step S410 the predictor 1102 proceeds to predict a future increase inoutput bitrate based on the weather forecast data in accordance withwhat was described with respect to step S304 of FIG. 3. Referring to theexample of FIG. 5a , the output bitrate is predicted to increase to thedashed curve 502 due to the weather affecting contents in the videostream.

In step S412, the output bitrate adjuster 1103 proceeds to increase thecompression level so as to compensate for the predicted increase inoutput bitrate caused by the weather, thereby making sure that the bitbudget is kept in the end. This is in accordance with what was describedin connection to step S306 of FIG. 3.

Generally, the output bitrate adjuster 1103 increases the compressionlevel during at least a time portion of the time interval T. However,the output bitrate adjuster 1103 may have different strategies forselecting when to increase the compression level so as to compensate forthe predicted increase in output bitrate. According to one strategy, thecompression level is increased during the predicted increase in outputbitrate. In other words, the periods when the compression level isincreased are selected based on the weather forecast data. This isillustrated by the dash-dotted curve 504 in FIG. 5b , which shows thefinal output bitrate for that case. According to another strategy, thecompression level is increased during the remainder of the time intervalT. This is illustrated by the dash-dotted curve 506 of FIG. 5c .According to yet another strategy, the compression level is increasedduring a time portion of the time interval T which is selected based onthe average bitrate curve 500. In more detail, the compression level maybe increased when the average bitrate curve is below a threshold. Thisis illustrated by the dash-dotted curve 508 in FIG. 5d , which shows thefinal output bitrate for that case. The threshold is denoted by B.According to still another strategy, the compression level is increasedbased on the contents of the video stream, such as when the level ofmotion in the video stream is below a threshold.

There may be different approaches for setting the amount of increase ofcompression level in step S412. Various things, such as the codec used,have an impact on the relation between compression level and outputbitrate. As further described above, also the severity of the weatherand the location of the camera has an impact on how much the compressionlevel should be increased. Certain testing is therefore required inorder to measure how the compression level affects the output bitratefor different cameras in different scenarios. However, it should also berecalled that due to the periodic adjustment in step S406 a furtherincrease of the compression level may be made if it is found that thecompression level was not increased enough in step S412. Conversely, ifthe compression level was increased too much in step S412, it may bedecreased again in the regular adjustment carried out in step S406. Thesystem is hence self-regulatory in that respect. However, whenincreasing the compression level in step S412, it may be wise toconsider the remaining bit budget and the remaining time of the timeinterval. Typically, the amount of increase in compression level shouldbe higher if there is only a short time remaining compared to if therehad been a longer time remaining, since the weather caused increase inbitrate has to be compensated for in a relatively short amount of time.Similarly, if there is only a low number of bits left to be spent, theamount of increase in compression level typically needs to be highercompared to if there had been more bits left to spend, since in thatsituation there are likely no spare bits left to spend on the weathercaused increase in bitrate.

The amount of the increase may further be determined based on the curve500 of previously collected bitrate data. In this way, the futureexpected bit costs, which may be deduced from the curve 500 may also betaken into account when deciding by how much the compression levelshould be increased to compensate for the weather caused increase inbitrate. For example, if there are high expected bit costs during theremainder of the time interval in relation to the remaining bits tospend, the increase in compression level typically needs to be highercompared to if the expected bit costs during the remainder of the timerinterval are low in relation to the remaining bits to spend. In otherwords, by comparing the remaining bit budget to the remaining expectedbit costs, it may be determined how many bits that may be spent on thefuture weather caused increase in bitrate. If it is found that there arenot enough remaining bits left to cover the weather caused increase inbitrate, the compression level should be increased. The amount ofincrease of the compression level is set such that the correspondingamount in reduction of output bitrate assures that the weather causedincrease in bitrate will be covered by the remaining bit budget.

It will be appreciated that a person skilled in the art can modify theabove-described embodiments in many ways and still use the advantages ofthe present teachings as shown in the embodiments above. Thus, thepresent teachings should not be limited to the shown embodiments butshould only be defined by the appended claims. Additionally, as theskilled person understands, the shown embodiments may be combined.

What is claimed is:
 1. A method for controlling output bitrate of avideo encoder when encoding a video stream, comprising: receivingweather forecast data including one or more weather related parametersfor a location where the video stream is captured; predicting, based onthe weather forecast data, a future increase in output bitrate of thevideo encoder due to weather affecting contents of the video stream,wherein a future increase in output bitrate is predicted by comparingthe one or more weather related parameters to predetermined thresholds;and reducing the output bitrate of the video encoder by increasing acompression level applied by the video encoder when compressing thevideo stream when a future increase in output bitrate has beenpredicted, thereby compensating for the future increase in outputbitrate of the video encoder.
 2. The method of claim 1, wherein the oneor more weather related parameters include at least one of a rain falllevel, a snow level, a moisture level, a temperature, and a wind speed.3. The method of claim 1, further comprising: setting a bit budgetcorresponding to a maximum number of bits that are allowed to be outputfrom the video encoder during a time interval; receiving previouslycollected bitrate data indicating an average temporal variation ofoutput bitrate of the video encoder during the time interval; andcalculating, from the previously collected bitrate data, a number ofbits which on average is output from the video encoder at a current timepoint of the time interval; and adjusting the compression level by:increasing the compression level if a number of bits that has beenoutput from the video encoder at the current time point exceeds thecalculated number of bits which on average is output from the videoencoder at the current time point, and decreasing the compression levelif the number of bits that has been output from the video encoder at thecurrent time point is below the calculated number of bits which onaverage is output from the video encoder at the current time point. 4.The method of claim 3, wherein the compression level of the video streamis adjusted periodically during the time interval.
 5. The method ofclaim 3, further comprising: keeping track of a number of bits that,according to the bit budget, remains to be output from the video encoderduring the time interval, and a remaining time of the time interval,wherein, in the step of reducing the output bitrate of the videoencoder, the compression level is increased by an amount which isdetermined based on at least the number of bits that remains to beoutput from the video encoder during the time interval, and theremaining time of the time interval.
 6. The method of claim 5, whereinthe amount is further determined based on the previously collectedbitrate data indicating an average temporal variation of output bitrateof the video encoder during the time interval.
 7. The method of claim 1,wherein the weather forecast data further indicates when in time aweather condition as specified by the one or more weather relatedparameters will occur, wherein the step of predicting includespredicting when there will be a future increase of output bitrate, andwherein, in the step of reducing the output bitrate, the compressionlevel of the video stream is increased during the predicted futureincrease of output bitrate of the video encoder.
 8. The method of claim3, wherein, in the step of reducing the output bitrate, the compressionlevel of the video stream is increased when the previously collectedbitrate data is below a predetermined threshold.
 9. The method of claim1, wherein, in the step of reducing the output bitrate, the compressionlevel of the video stream is increased until further notice.
 10. Themethod of claim 1, wherein, in the step of reducing the output bitrate,the compression level is increased during periods when the level ofmotion in the video stream is below a threshold.
 11. A controller forcontrolling output bitrate of a video encoder when encoding a videostream, comprising: a receiver configured to receive weather forecastdata including one or more weather related parameters for a locationwhere the video stream is captured; a predictor configured to predict,based on the weather forecast data, a future increase in output bitrateof the video encoder due to weather affecting contents of the videostream wherein a future increase in output bitrate is predicted bycomparing the one or more weather related parameters to predeterminedthresholds; and an output bitrate adjuster configured to reduce theoutput bitrate of the video encoder by increasing a compression levelapplied by the video encoder when compressing the video stream when afuture increase in output bitrate has been predicted, therebycompensating for the future increase in output bitrate of the videoencoder.
 12. A video camera comprising a video encoder and a controlleraccording to claim 11 for controlling output bitrate of the videoencoder.
 13. A non-transitory computer-readable medium havinginstructions stored thereon for controlling output bitrate of a videoencoder when encoding a video stream, execution of which by a computingdevice causes the computing device to perform operations comprising:receiving weather forecast data including one or more weather relatedparameters for a location where the video stream is captured;predicting, based on the weather forecast data, a future increase inoutput bitrate of the video encoder due to weather affecting contents ofthe video stream, wherein a future increase in output bitrate ispredicted by comparing the one or more weather related parameters topredetermined thresholds; and reducing the output bitrate of the videoencoder by increasing a compression level applied by the video encoderwhen compressing the video stream when a future increase in outputbitrate has been predicted, thereby compensating for the future increasein output bitrate of the video encoder.